package com.tianpengtech.front.mobile.common.util;

import com.jfinal.kit.StrKit;
import com.tianpengtech.front.mobile.common.constant.Constant;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;


/**
 * Created by ggd on 2017/7/19 0019.
 */
public class U {

    public static boolean isMobile(String mobile){
        if (StrKit.isBlank(mobile)){
            return false;
        }
        Pattern pattern = Pattern.compile(Constant.REGEX_MOBILE);
        Matcher matcher = pattern.matcher(mobile);
        if(matcher.matches()) {
           return true;
        }else{
            return false;
        }
    }

    public static boolean isInteger(String val){
        if (StrKit.isBlank(val)){
            return false;
        }
        Pattern pattern = Pattern.compile(Constant.REGEX_INTERGER);
        Matcher matcher = pattern.matcher(val);
        if(matcher.matches()) {
            return true;
        }else{
            return false;
        }
    }

    public static boolean isMoney(String val){
        if (StrKit.isBlank(val)){
            return false;
        }
        Pattern pattern = Pattern.compile(Constant.REGEX_MONEY);
        Matcher matcher = pattern.matcher(val);
        if(matcher.matches()) {
            return true;
        }else{
            return false;
        }
    }


    public static void main(String[] args) {
        System.out.println(isMobile("15655375939"));
    }


    public static boolean isValidPass(String password){
    	
    	boolean result=true;
    	if(StringUtils.isBlank(password)){
    		result =  false;
    	}else if(StringUtils.length(password)<6 || StringUtils.length(password)>30 ){
    		result =  false;
    	}
    	return result;
    }
}
